<template>
	<div class="kp-content">
		<div class="seat-top">
			<p>{{ todos.filmName }}</p>
			<p>{{ todos.week.week }}&nbsp;{{todos.week.datestr}}&nbsp;{{todos.showStartTime}}<span>{{todos.item.language}}{{todos.item.showVersionType}}</span></p>
		</div>
		<div class="select-block">
			<div class="hall-name-wrapper" id="yinmu">
				<span>{{ todos.hallName}}银幕</span>
			</div>
			<div class="warp-center" id="center_movie"><span>屏幕中央</span></div>
			<div class="seats-block" ref="seatsBlock" :style="{height:height/75+'rem'}" id="touchs">
				<!--中线  -->
				<div class='middle' id="middle" ref="middle"></div>
				<div class="setcon">
					<div class="left-list" id="left-list" ref="leftList" :style="{transform: 'translateX('+numLeft/75+'rem)'}">
						<div class="left-lists">
							<div class="list" v-for="(item,index) in seats" :key="index">{{item.rowList[0].rowId}}</div>
						</div>
					</div>
					<div class="seats-wrap" ref="touchs">
						<div class="" v-for="(item,index1) in setdata" :key="index1">
							<div class="seats" v-for="(items,index) in item.seats" :key="index">
								<div class="" v-for="(itemss,indexs) in items.rowList" ref="warp" :key="indexs" :class='itemss.warpC'>
									<img :src="itemss.imgsrc" :data-seatz='itemss.seatZ' :data-status='itemss.status' :data-origStatus="itemss.origStatus" :data-listIndex="index" :data-rowIndex="indexs" :data-key="index1" :class='itemss.classS' @click="choose($event)" v-if="itemss.imgsrc!=''" />
									<img v-else :data-status='itemss.status' :data-origStatus="itemss.origStatus" :data-listIndex="index" :data-rowIndex="indexs" :data-key="index1" />
								</div>
							</div>
						</div>
					</div>

				</div>

			</div>
		</div>
		<div class="cinema-info" v-if="chooseList.length == 0">
			<div class="seat-type-info">
				<p><span></span><span>可选</span></p>
				<p><span></span><span>不可选</span></p>
				<p><span></span><span>已选</span></p>
				<p v-if="loversFlag"><span></span><span>情侣座</span></p>
			</div>
		</div>
		<div class="seat_divbox">
			<div class="seat-selection" v-if="chooseList.length != 0">
				<p>已选座位</p>
				<div class="seat-selection-list">
					<div class="list" v-for="(item,index) in chooseList" :key="index" @click="del($event)" :data-index='index'>
						<span>{{item.rowId}}排{{item.columnId}}座</span>
						<span>{{ settlePriceForMerchant}}元</span>
						<span><img @click="cancels(item)" src="@/assets/shanchu-piao@2x.png"></span>
					</div>
				</div>
			</div>
			<div class="submit-block" :class="chooseList.length?'active':''">
				<p v-if="chooseList.length" @click="confirm($event)">{{ allPrice }}元 确认选座</p>
				<p v-else="">请优先选座</p>
			</div>
		</div>
		<Realname v-if="isRealname"></Realname>
	</div>
</template>

<script>
	import { mapState } from "vuex";
	import common from '../public/sha512';
	import Realname from "./Realname"; //占座
	export default {
		props: ["todos"],
		data() {

			return {
				seatList: {

				},
				showId: "",
				cinemaId: "",
				hallId: "",
				movieId: '',
				cinemaName: '', //影院名称
				filmName: '', //影片名称
				seats: '',
				rowSum: '', //行数
				scale: 1,
				translateX: 0,
				translateY: 0,
				Select: [], //选中普通座的数组
				SelectQl: [], //选中情侣座的数组
				selects: [], //普通座位选中数据
				//				buyNumLimit: '1', //最多购买座位数量
				about: '', //判断座位从那边数
				ql: "", //如果情侣座true 否则false
				Ticket: '',
				Tickets: '',
				title: "",
				seatsJSON: {
					"count": "",
					list: []
				}, //座位信息
				orderSeat: '', //当前用户已选座位信息
				isp: false,
				price: '',
				settlePriceForMerchant: '',
				tranX: '',
				tranY: '',
				height: 900,
				numLeft: -350, //辅助数字的偏移量
				dataDay: '',
				film_showStartTime: '',
				setdata: {}, //座位的列表
				rowNumBoxList: [],
				loversFlag: false, //情侣座
				isIcon: true, //是否有Icon
				allPrice: '',
				chooseList: [],
				buyNumLimit: '', //锁座上限数量
				setFlag: true,
				buyListNum:0,
				isRealname:false,//是否实名认证
			}

		},
		filters: {
			week: function(str) { //放映日期
				var week, dats;
				if(str) {
					week = str.split(' ')[0];
					dats = str.split(' ')[1];
					var s1 = dats.split(':')[0];
					var s2 = dats.split(':')[1];

					function GetDateStr(AddDayCount) {
						var dd = new Date();
						dd.setDate(dd.getDate() + AddDayCount); //获取AddDayCount天后的日期 
						var y = dd.getFullYear();
						var m = dd.getMonth() + 1; //获取当前月份的日期 
						var d = dd.getDate();
						m = m > 9 ? m : ("0" + m);
						d = d > 9 ? d : ("0" + d);
						return y + "-" + m + "-" + d;
					}
					var toDay = GetDateStr(0); //今天
					var tomorrow = GetDateStr(1); //明天
					function toWeek(str) {
						var s = str.split('-')[1].replace('0', "");
						var s1 = str.split('-')[2].replace('0', "");
						return s + '月' + s1 + "日"
					}

					function getMyDay(date) {
						var dates;
						if(date.getDay() == 0) dates = "周日"
						if(date.getDay() == 1) dates = "周一"
						if(date.getDay() == 2) dates = "周二"
						if(date.getDay() == 3) dates = "周三"
						if(date.getDay() == 4) dates = "周四"
						if(date.getDay() == 5) dates = "周五"
						if(date.getDay() == 6) dates = "周六"
						return dates;
					}
					if(week == toDay) {
						week = "今天" + toWeek(week);
					} else if(week == tomorrow) {
						week = "明天" + toWeek(week);
					} else {
						week = getMyDay(new Date(week)) + toWeek(week);
					}
					return week + s1 + ':' + s2;
				}
			},
		},
		mounted: function() {

			sessionStorage.setItem('currentCoupon', JSON.stringify({})) //储存优惠券信息
			this.pics();
			this.cinemaName = sessionStorage.getItem("cinemaNameSeat");
			this.filmName = sessionStorage.getItem("filmNameSeat");
			this.showId = this.todos.showId;
			this.hallId = this.todos.hallCode;
			this.movieId = this.todos.filmId;
			//			this.seat();
			this.buyNumLimit = this.todos.buyNumLimit;
			this.settlePriceForMerchant = Number(this.todos.item.settlePriceForMerchant).toFixed(1);
			this.dataDay = this.todos.item.showTime.split(' ')[0];
			if(localStorage.getItem('film_showStartTime')) {
				this.film_showStartTime = localStorage.getItem('film_showStartTime');
			}
			//选座接口
			this.getsetdata();
		},
		methods: {
			getsetdata() {
				this.$loading.show();
				var that = this;
				var param = {
					showId: this.todos.item.showId,
					cinemaId: this.cinemaId,
					hallCode: this.todos.item.hallCode,
					movieId: this.todos.filmId
				};
				this.$http.post(this.$baseUrl.baseurl + 'mymovie/movie/dynamicSeatList', param).then((res) => {
					if(res.data.Code == 0) {
						if(res.data.Result.sections) {
							var sections = res.data.Result.sections;
							var flag = true; //是否有Icon
							var loversFlag = false; //是否有情侣座
							//							var setFlag = true; //是否满座
							var num = 0; //多少排
							sections.forEach((val, key) => {
								num = val.seats.length + num;
								val.seats.forEach((item, index) => {
									var cinemaSeats = item.rowList;
									item.rowList.forEach((item2, index2) => {
										(item2.status != "LK" && item2.status != "E") && (that.setFlag = false); //判断是否满座
										(item2.origStatus == "L") && (loversFlag = true); //情侣座
										if(res.data.Result.icons) { //有icon
											if(item2.status == 'N' || item2.status == 'L' || item2.status == 'R') { //可选座
												if(item2.origStatus == 'L') { //情侣座左
													if(cinemaSeats[index2 - 0 + 1].status == 'E' || cinemaSeats[index2 - 0 + 1].status == 'LK') {
														item2.imgsrc = res.data.Result.icons.noSelectedIconUrl || 'http://h5.kpcx179.com/wximages/zuoweikexuan@2x.png'
														item2.classS = 'set'
														item2.warpC = 'wrap'
														item2.seatZ = 'N'
													} else {
														item2.imgsrc = res.data.Result.icons.loversNoSelectedIconUrl || 'http://h5.kpcx179.com/wximages/zuowei-qinglvzuo@2x.png'
														item2.classS = 'setL'
														item2.warpC = 'wrapL'
														item2.seatZ = 'L'
													}
												} else if(item2.origStatus == 'R') { //情侣座右
													item2.imgsrc = '';
													item2.classS = 'setR';
													item2.warpC = 'wrapR'
													item2.seatZ = ''
												} else { //
													item2.imgsrc = res.data.Result.icons.noSelectedIconUrl || 'http://h5.kpcx179.com/wximages/zuoweikexuan@2x.png'
													item2.classS = 'set'
													item2.warpC = 'wrap'
													item2.seatZ = 'N'
												}
											} else if(item2.status == 'E') { //过道
												item2.imgsrc = ''
												item2.classS = ''
												item2.warpC = 'wrap'
												item2.seatZ = ''
											} else if(item2.status == 'LK') { //不可选LK 
												if(item2.origStatus == "L") {
													if(cinemaSeats[index2 - 0 + 1].status == 'E') {
														item2.imgsrc = res.data.Result.icons.opSelectedIconUrl || 'http://h5.kpcx179.com/wximages/zuoweibukexuan@2x.png';
														item2.classS = 'set'
														item2.warpC = 'wrap'
													} else {
														item2.imgsrc = res.data.Result.icons.opSelectedIconUrl || 'http://h5.kpcx179.com/wximages/qinglvzuo-bukexuan@2x.png';
														item2.classS = 'setL';
														item2.warpC = 'wrapL'
													}
												} else if(item2.origStatus == "R" && item2.status == 'LK' && cinemaSeats[index2 - 1].origStatus == 'L' && cinemaSeats[index2 - 1].status == 'N') {
													item2.imgsrc = '';
													item2.classS = ''
													item2.warpC = 'wrap'
												} else if(item2.origStatus == "R") {
													item2.classS = 'setR';
													item2.warpC = 'wrapR';
													item2.imgsrc = '';
												} else {
													item2.imgsrc = res.data.Result.icons.opSelectedIconUrl || 'http://h5.kpcx179.com/wximages/zuoweibukexuan@2x.png';
													item2.classS = 'set';
													item2.warpC = 'wrap'
												}
											};
										} else { //没有icon
											flag = false;
											if(item2.status == 'N' || item2.status == 'L' || item2.status == 'R') { //可选座
												if(item2.origStatus == 'L') { //情侣座左
													if(cinemaSeats[index2 - 0 + 1].status == 'E' || cinemaSeats[index2 - 0 + 1].status == 'LK') {
														item2.imgsrc = 'http://h5.kpcx179.com/wximages/zuoweikexuan@2x.png';
														item2.classS = 'set'
														item2.warpC = 'wrap'
														item2.seatZ = 'N'
													} else {
														item2.imgsrc = 'http://h5.kpcx179.com/wximages/zuowei-qinglvzuo@2x.png';
														item2.classS = 'setL'
														item2.warpC = 'wrapL'
														item2.seatZ = 'L'
													}

												} else if(item2.origStatus == 'R') { //情侣座右
													item2.imgsrc = '';
													item2.classS = 'setR';
													item2.warpC = 'wrapR'
													item2.seatZ = ''

												} else {
													item2.imgsrc = 'http://h5.kpcx179.com/wximages/zuoweikexuan@2x.png';
													item2.classS = 'set'
													item2.warpC = 'wrap'
													item2.seatZ = 'N'
												}
											} else if(item2.status == 'E') { //过道或情侣座右
												item2.imgsrc = '';
												item2.classS = ''
												item2.warpC = 'wrap'
											} else if(item2.status == 'LK') { //不可选LK 
												//item2.imgsrc = (item2.origStatus == "L") ? "http://h5.kpcx179.com/wximages/qinglvzuo-bukexuan@2x.png" : 'http://h5.kpcx179.com/wximages/zuoweibukexuan@2x.png';
												if(item2.origStatus == "L") {
													if(cinemaSeats[index2 - 0 + 1].status == 'E') {
														item2.imgsrc = 'http://h5.kpcx179.com/wximages/zuoweibukexuan@2x.png';
														item2.classS = 'set'
														item2.warpC = 'wrap'
													} else {
														item2.imgsrc = 'http://h5.kpcx179.com/wximages/qinglvzuo-bukexuan@2x.png';
														item2.classS = 'setL';
														item2.warpC = 'wrapL'
													}
												} else if(item2.origStatus == "R" && item2.status == 'LK' && cinemaSeats[index2 - 1].origStatus == 'L' && cinemaSeats[index2 - 1].status == 'N') {
													item2.imgsrc = '';
													item2.classS = ''
													item2.warpC = 'wrap'
												} else if(item2.origStatus == "R") {
													item2.classS = 'setR';
													item2.warpC = 'wrapR';
													item2.imgsrc = '';
												} else {
													item2.imgsrc = 'http://h5.kpcx179.com/wximages/zuoweibukexuan@2x.png';
													item2.classS = 'set';
													item2.warpC = 'wrap'
												}
											};
										};
									});
								});
							});
							// console.log(setFlag);
							//数字辅助的实现
							var rowNumBoxList = [];
							sections.forEach(val => {
								var num = 0;
								var arr = [];
								val.seats.forEach((item) => {
									arr.push(item.rowList[0].rowId);
								});
								rowNumBoxList.push(arr);
							});

							that.setdata = sections;
							that.seats = sections[0].seats;
							//							console.log(that.seats)
							that.isIcon = flag;
							that.height = num * 50 + 200;
							that.rowNumBoxList = rowNumBoxList;
							that.loversFlag = loversFlag;
							that.getUresMgs();

						} else {
							that.$toast(res.data.msg);
							setTimeout(function() {
								that.$router.go(-1);
							}, 2000);
						}
						that.$loading.hide();
					}
				}).catch((err) => {
					this.$loading.hide();
					console.log(err);
				})
			},
			getUresMgs() { //获取用户购票信息
				//获取用户已购座位信息
				let that = this;
				var param = {
					userID: that.userInfo.userID,
					showId: that.todos.item.showId,
				};
				this.$http.post(this.$baseUrl.baseurl + 'mymovie/movie/AppChoosedSeat', param).then((res) => {
					if(res.data.Result.orderNum) { //有订单号说明下单了需要处理
						//找出对应的座位
						var cinemaList = res.data.Result.orderSeat;
						that.buyListNum = Number(cinemaList.length);
						res.data.Result.orderSeat.forEach((item, index) => {
							that.setdata.forEach((val, keyB) => {
								val.seats.forEach((itemR, keyR) => {
									var seatCinema = itemR.rowList;
									itemR.rowList.forEach((itemA, keyA) => {
										if(item.seatNo == itemA.seatNo) {
											that.setFlag = false;
											//改变状态
											itemA.status = item.origStatus;
											if(itemA.status == 'N' || itemA.status == 'L') {
												if(itemA.origStatus == 'L') {
													if(cinemaList[index - 0 + 1].seatNo == seatCinema[keyA - 0 + 1].seatNo) {
														itemA.imgsrc = "http://h5.kpcx179.com/wximages/qinglvzuo-yixuan@2x.png"
														itemA.classS = 'setL'
														itemA.warpC = 'wrapL'
														itemA.seatZ = 'L'
													} else {
														itemA.imgsrc = 'http://h5.kpcx179.com/wximages/zuowei-yixuan@2x.png';
														itemA.classS = 'set'
														itemA.warpC = 'wrap'
														itemA.seatZ = 'N'
														seatCinema[keyA - 0 + 1].classS = 'set';
														seatCinema[keyA - 0 + 1].warpC = 'wrap';
														seatCinema[keyA - 0 + 1].imgsrc = '';
													}
												} else {
													itemA.imgsrc = "http://h5.kpcx179.com/wximages/zuowei-yixuan@2x.png"
													itemA.seatZ = 'N'
												}
											}
											//											(item.origStatus == "L") && (itemA.imgsrc = "http://h5.kpcx179.com/wximages/qinglvzuo-yixuan@2x.png");
											//											(item.origStatus == "R") && (itemA.imgsrc = "");
											//											(item.origStatus == "N") && (itemA.imgsrc = "http://h5.kpcx179.com/wximages/zuowei-yixuan@2x.png");
											itemA.stute = 1; //改变状态
											//存行列区
											itemA.listindex = keyR;
											itemA.rowindex = keyA;
											itemA.key = keyB;
											//添加座位
											that.chooseList.push(itemA);
										}
									})
								})
							})
						})
						that.setFlag && that.$alert({
							title: '',
							content: '该场次的座位已满',
							btnText: '我知道了',
						}).then(function(res) {

						}).catch(function(err) {
							console.log(err)
						})
						//计算总价格
						that.allPrice = Number(that.todos.item.settlePriceForMerchant * that.chooseList.length).toFixed(1);
					}
				}).catch((err) => {

				})
			},
			choose(e) {
//				console.log(e.target.dataset.seatz)
				if(this.chooseList[0] && (this.chooseList[0].key != e.target.dataset.key)) {
					that.$alert({
						title: '',
						content: '一次只能购买同一场区的票',
						btnText: '我知道了',
					}).then(function(res) {
						that.$router.go(-1);
					}).catch(function(err) {
						console.log(err)
					})
					return;
				};
				if(e.target.dataset.status == "N" || e.target.dataset.status == "L") { //该座可以选
					var obj = this.setdata[e.target.dataset.key].seats[e.target.dataset.listindex].rowList[e.target.dataset.rowindex]; //存一下该节点的对象
					var objNext = (e.target.dataset.seatz == "L") ? (this.setdata[e.target.dataset.key].seats[e.target.dataset.listindex].rowList[e.target.dataset.rowindex - 0 + 1]) : null; //存一下该节点下一个节点的对象，情侣座情况

					// console.log(this.data.setdata.seats[e.target.dataset.listindex]);//获取该列的座位
					//console.log(obj);
					//console.log(objNext);
					//存行列区
					obj.key = e.target.dataset.key;
					obj.listindex = e.target.dataset.listindex;
					obj.rowindex = e.target.dataset.rowindex;
					if(objNext) { //情侣座
						objNext.key = e.target.dataset.key;
						objNext.listindex = e.target.dataset.listindex;
						objNext.rowindex = Number(e.target.dataset.rowindex) + 1;
					}
					//开始判断
					if(obj.stute) { //已经选中
						//删除该选中的座位
						if(e.target.dataset.seatz=='N'){
							this.buyListNum -=1;
						}else if(e.target.dataset.seatz == 'L'){
							this.buyListNum -=2;
						}
						console.log(this.buyListNum)
						var key = null;
						this.chooseList.forEach((item, index) => {
							// console.log(item);
							(item.seatNo == obj.seatNo) && (key = index); //获取到对应的索引
						})
						//删除seatZ
						var num = ((e.target.dataset.status == "N" && e.target.dataset.seatz == "L") || (e.target.dataset.status == 'L' && e.target.dataset.seatz == "L")) ? 2 : 1; //情侣座删除俩
						this.chooseList.splice(key, num);
						obj.imgsrc = ((e.target.dataset.status == "N" && e.target.dataset.seatz == "L") || (e.target.dataset.status == 'L' && e.target.dataset.seatz == "L")) ? 'http://h5.kpcx179.com/wximages/zuowei-qinglvzuo@2x.png' : "http://h5.kpcx179.com/wximages/zuoweikexuan@2x.png"; //改变图片
						//改变状态
						obj.stute = 0;
						//计算总价格
						this.allPrice = Number(this.todos.item.settlePriceForMerchant * this.chooseList.length).toFixed(1);
					} else { //未选中
						//var num = ((e.target.dataset.status == "N" && e.target.dataset.seatz == "L") || (e.target.dataset.status == 'L' && e.target.dataset.seatz == "L")) ? this.buyNumLimit : (this.buyNumLimit - 1); //限制最大的购票数
						if(e.target.dataset.seatz=='N'){
							this.buyListNum +=1;
						}else if(e.target.dataset.seatz == 'L'){
							this.buyListNum +=2;
						}
						console.log(this.buyListNum)
						var num = Number(this.todos.buyNumLimit);
						if(this.buyListNum <= num) { //小于规定张数选中
							obj.imgsrc = ((e.target.dataset.status == "N" && e.target.dataset.seatz == "L") || (e.target.dataset.status == 'L' && e.target.dataset.seatz == "L")) ? "http://h5.kpcx179.com/wximages/indexIcon/qinglvzuo-yixuan@2x.png" : "http://h5.kpcx179.com/wximages/zuowei-yixuan@2x.png"; //改变图片
							obj.stute = 1; //改变状态
							//添加行列
							this.chooseList.push(obj);
							// console.log(objNext);
							//情侣座多加一个
							(e.target.dataset.seatz == "L") && (this.chooseList.push(objNext));
							//计算总价格
							this.allPrice = Number(this.todos.item.settlePriceForMerchant * this.chooseList.length).toFixed(1);
						} else { //大于规定张数
							this.$toast('一次最多选择' + this.todos.buyNumLimit + '个座位');
							if(e.target.dataset.seatz=='N'){
								this.buyListNum -=1;
							}else if(e.target.dataset.seatz == 'L'){
								this.buyListNum -=2;
							}
						}
					}

				}
			},
			del(e) {
				var key = e.currentTarget.dataset.index;

				//存一下该节点
				var obj = this.setdata[this.chooseList[key].key].seats[this.chooseList[key].listindex].rowList[this.chooseList[key].rowindex];
				//console.log(obj)
				//改变图片
				//确定改变的对象
				var objConfirm = (obj.origStatus == "R") ? this.setdata[this.chooseList[key].key].seats[this.chooseList[key].listindex].rowList[this.chooseList[key].rowindex - 1] : obj;
				//console.log(objConfirm)
				//替换该对象图片
				objConfirm.imgsrc = ((obj.status == "N" && e.target.dataset.seatz == "L") || (obj.status == 'L' && obj.origStatus == "L")) ? 'http://h5.kpcx179.com/wximages/zuowei-qinglvzuo@2x.png' : "http://h5.kpcx179.com/wximages/zuoweikexuan@2x.png";
				//改变状态
				objConfirm.stute = 0;
				if(obj.status == "N" || obj.status == 'L' || obj.status == 'R') {
					if(obj.origStatus == "L") {
						this.chooseList.splice(key, 2);
					} else if(obj.origStatus == "R") {
						this.chooseList.splice(key - 1, 2);
					} else {
						this.chooseList.splice(key, 1)
					}
				}
				//删除对应的选中的座位
				//				(obj.status == "N") && this.chooseList.splice(key, 1);
				//				//情侣座多删除一个
				//				(obj.status == "N"&&obj.origstatus == "L") && this.chooseList.splice(key, 2);
				//				(obj.origstatus == "R") && this.chooseList.splice(key - 1, 2);
				//计算总价格
				this.allPrice = Number(this.todos.item.settlePriceForMerchant * this.chooseList.length).toFixed(1);
			},
			confirm(e) { //确认选座
				//this.todos.payFlag = true;
				//console.log(this.todos.payFlag)
				this.$emit('pay', true)
				//this.$loading.show();
				// console.log(this.data.chooseList, this.data.allPrice);
				//获取分区
				var key = Number(this.chooseList[0].key);
				//console.log(key)
				//通过返回值进行下一步
				//调用函数检测选座是否符合规则
				var flag = this.isEmptySeatFlag(this, key);
				var that = this;
				//console.log(flag)
				//return;
				if(flag) { //OK跳转支付页面
					if(!this.userInfo && (typeof this.userInfo.userID) == 'undefined') { //未登录
						this.$router.push({
							path: '/login',
						})
					} else { //已登录
						if(this.userInfo && this.userInfo.realnamestatus) { //如果实名认证了
							this.$loading.show();
							//								that.$toast('订单创建中');
							var seatsJSON = {
								"count": this.chooseList.length, //购票的数量
								"list": [], //座位信息
							};
							this.chooseList.forEach((item) => {
								var obj = {
									"sectionId": item.sectionsID, //场区Id
									"seatNo": item.seatNo, //座位编号
									"columnId": item.columnId, //座位列ID
									"rowId": item.rowId //座位行Id
								};
								seatsJSON.list.push(obj);
							});
							let totalPrice =  Math.round(this.price);
							console.log(this.allPrice)
							let seatsJSON = JSON.stringify(seatsJSON);
							console.log(this.todos.item)
							let param = {
								'userID': this.userInfo.userID,
								'payMoney': this.allPrice, //实际支付金额
								'totalPrice':this.allPrice, //订单总金额
								'activityID': "-1", //活动id
								'cinemaId': Number(this.todos.cinemaid), //影院id
								'cinemaName': this.todos.cinemaName, //影院名称
								'hallCode': this.todos.item.hallCode, //影厅编码
								'hallName': this.todos.item.hallName, //影厅名字
								'filmId': this.todos.item.filmId, //影片id
								'filmName': this.todos.item.filmName, //影片名称
								'showId': this.todos.item.showId, //影讯id
								'showStartTime': this.todos.item.showTime, //放映开始时间
								'settlePriceForMerchant': Number(this.todos.item.settlePrice), //渠道结算价
								'settlePriceForCinema': this.todos.item.settlePriceForCinema, //影院结算价
								'fee': Number(this.todos.item.fee), //猫眼服务费
								'price': this.todos.item.price, //原价
								'minPrice': this.todos.item.minPrice, //最低价
								'contactName': this.userInfo.userName, //联系人姓名
								'contactMobile': this.userInfo.phone, //联系人电话
								'language': this.todos.item.language, //放映语言
								'showVersionType': this.todos.item.showVersionType, //影讯版本
								'channels': 3,
								'seatsJSON': seatsJSON, //选中座位信息
								//									'seatsJSON': "{\"count\":1,\"list\":[{\"sectionId\":\"0000000000000001\",\"seatNo\":\"0000000000000001-6-08\",\"columnId\":\"08\",\"rowId\":\"6\"}]}", //选中座位信息
								'deviceID': '', //机型
								'model': "",
								'os': '', //手机版本
								'ip': '', //ip
								'avatar': this.todos.item.avatar,
								'movieDur': this.todos.item.duration,
								'wxApplet': 'wxApplet'

							};
							//								var header = {"token":this.userInfo.token};
							this.$http.post(this.$baseUrl.baseurl + 'mymovie/movie/appSaveOrder', param).then((res) => {
								if(res.data.Code == 0) {
									that.$router.push({
										path: '/index/film/pay',
										query: {
											//												"result":JSON.stringify(res.data.Result)
											"lockSurTime": res.data.Result.lockSurTime,
											"orderNum": res.data.Result.order_num,
										}
									})
									this.$store.commit('FILM_ORDERNUM', res.data.Result.order_num)
									this.$loading.hide();
								} else if(res.data.Code == 3) {
									this.$loading.hide();
									that.$toast('请登录');
									that.$router.push({
										path: '/login',
									})
								} else {
									this.$loading.hide();
									//"102 上映开始X分钟前禁止售卖
									that.$toast(res.data.msg);
								}
							}).catch((err) => {
								this.$loading.hide();
								console.log(err);
							})
						} else {
							//实名认证
							this.isRealname = true;

						}
					}

				} else { //提示有空座
					this.$toast('不能留空座');
				}

			},
			isEmptySeatFlag(that, key) { //封装一个函数判断是否出现了选座中出现空座的情况
				var flag = true; //最终结果true表示选座OK
				//数组深拷贝
				var arr = JSON.parse(JSON.stringify(that.setdata[key].seats));
				//改写情侣座的状态
				arr.forEach((item) => {
					item.rowList.forEach((item) => {
						(item.status == "L" || item.status == "R") && (item.status = "N");
					})
				})

				function flagSeat(direction, that, item) { //封装函数单个座位的判断
					//console.log(item);
					//拿到座位先判断是否为该行的最后俩个
					function two() {
						var flag = true; //判断循环是否结束
						var i = 0; //总数量
						var num = 0; //左右推进数值
						while(flag) { //向左数
							var obj = arr[item.listindex].rowList[item.rowindex - num];
							(obj && obj.status == "N") ? (i++) : (flag = false);
							num++;
						};
						//初始化变量
						num = 0;
						flag = true;
						while(flag) { //向右数
							var obj = arr[item.listindex].rowList[item.rowindex - 0 + num];
							(obj && obj.status == "N") ? (i++) : (flag = false);
							num++;
						}
						return i - 1;
					}
					var num = two(); //输出数量
					// console.log(num);
					if(num > 3) { //3座以上遵循规则
						//direction true 为左 false 为右;
						//拿到座位
						if(direction) { //左
							var seatOne = arr[item.listindex].rowList[item.rowindex - 1];
							var seatTwo = arr[item.listindex].rowList[item.rowindex - 2];
						} else { //右
							var seatOne = arr[item.listindex].rowList[item.rowindex - 0 + 1];
							var seatTwo = arr[item.listindex].rowList[item.rowindex - 0 + 2];
						}
						//如果存在判断座位的状态,不存在此座位肯定可买
						if(seatOne && seatOne.status == "N") { //如果为可选座位判断是否已经选中
							var flags = true; //表示未存在
							//从用户已选座位中寻找是否有该座位
							that.chooseList.forEach((itemS) => {
								// console.log(item.seatNo);
								(seatOne.seatNo == itemS.seatNo) && (flags = false); //存在座位可以跳过该座位该方向的判断
							})
							if(flags) { //未存在则判断是否卡座,存在跳出函数进行下一个座位或方向的判断
								
								if(seatTwo && seatTwo.status == "N") { //判断是否已选择 是否卡座
									// console.log(seatTwo.seatNo);
									//从用户已选座位中寻找是否有该座位
									that.chooseList.forEach((itemS) => {
										// console.log(item.seatNo);
										(seatTwo.seatNo == itemS.seatNo) && (flag = false); //存在座位不可选
									})
								} else { //推俩个位置不存在说明卡座情况可能出现
									//console.log(seatOne);
									//当购买者从此坐左右偏移到无可购买都已买到即可买票
									var num = 0; //左右推进数值
									var i = 0; //选中的座位数
									var flagS = true; //循环的判断值
									while(flagS) {
										var obj = arr[item.listindex].rowList[item.rowindex-0 + num];
										(direction) ? (num++) : (num--); //左加右减向反方向去验证                 
										if(obj && obj.status == "N") { //如果存在且为可选
											//判断是否已选择
											that.chooseList.forEach((item) => { //判断中间的是否选中
												(obj.seatNo == item.seatNo) && (i++); //表示被选中
											})
										} else { //否则停止循环
											flagS = false;
										}
									};
									//格式化num
									num = (num > 0) ? num : (-num);
									//输出
									// console.log(i,num);
									(i == (num - 1)) || (flag = false);
								}
							}
						}
					} else if(num == 3) { //3座 
						var obj = null; //中间的座位
						var index = null; //中间座位的索引
						//拿到现在的座位进行判断
						var objOne = arr[item.listindex].rowList[item.rowindex - 1];
						var objTwo = arr[item.listindex].rowList[item.rowindex - 2];
						if(objOne.status == "N") { //左一是
							if(objTwo.status == "N") { //左二也是
								//即左一为中
								obj = arr[item.listindex].rowList[item.rowindex - 1];
								index = item.rowindex - 1;
							} else { //左二不是
								//即本身为中
								obj = arr[item.listindex].rowList[item.rowindex];
								index = item.rowindex;
							}
						} else { //左一不是,即右一为中
							obj = arr[item.listindex].rowList[item.rowindex - 0 + 1];
							index = item.rowindex - 0 + 1;
						}
						//获取中间的座位
						var isFlag = false; //判断中间的座位是否被选中
						that.chooseList.forEach((item) => { //判断中间的是否选中
							(obj.seatNo == item.seatNo) && (isFlag = true); //表示被选中
						})
						//拿到左右
						var left = arr[item.listindex].rowList[index - 1];
						var right = arr[item.listindex].rowList[index - 0 + 1];
						if(isFlag) { //选中判断两边有一个选中即可
							var flagS = false;
							that.chooseList.forEach((item) => { //判断是否选中
								(left.seatNo == item.seatNo) && (flagS = true);
								(right.seatNo == item.seatNo) && (flagS = true);
							})
							//输出结果
							flag = flagS;
						} else { //未选中判断两边都选不可以
							var i = 0;
							that.chooseList.forEach((item) => { //判断是否选中
								(left.seatNo == item.seatNo) && (i++);
								(right.seatNo == item.seatNo) && (i++);
							})
							flag = (i == 2) ? false : true;
						}
					} else {} //2座以下随便购买
				}
				this.chooseList.forEach((item) => { //遍历已选择的座位
					flagSeat(true, that, item); //判断左
					flagSeat(false, that, item); //判断右
				})
				// console.log(flag);   
				return flag;
			},

			seat: function() {
				this.$loading.show();
				var timestamp = new Date().format('yyyy-MM-dd hh');
				var paramObj = {
					showId: this.todos.item.showId,
					cinemaId: this.cinemaId,
					hallCode: this.todos.item.hallCode,
					movieId: this.todos.filmId
				};
				var that = this;
				this.$http.post(this.$baseUrl.baseurl + 'mymovie/movie/dynamicSeatList', paramObj).then(function(data) {
					if(data.data.Code == 0) {

						var seatss = data.data.Result.sections[0];
						that.seats = seatss.seats;
						var num = 0;
						num = that.seats.length + num;
						that.height = num * 55 + 200;
						var setFlag = true; //是否满座
						that.seats.forEach((item, index) => {
							item.rowList.forEach((item2, index2) => {
								(item2.status != "LK" && item2.status != "E") && (setFlag = false); //判断是否满座
							});
						});
						setFlag && that.$alert({
							title: '',
							content: '该场次的座位已满',
							btnText: '我知道了',
						}).then(function(res) {
							that.$router.go(-1);
						}).catch(function(err) {
							console.log(err)
						})
						if(that.userInfo.userID) { //用户选择座位信息
							var timestamp = new Date().format('yyyy-MM-dd hh');
							var paramObj = {
								userID: that.userInfo.userID,
								showId: that.todos.item.showId,
							};
							var headers = {
								'Content-Type': 'application/x-www-form-urlencoded'
							};
							that.$http.post(that.$baseUrl.baseurl + 'mymovie/movie/AppChoosedSeat', paramObj, headers, {
								emulateJSON: true
							}).then(function(data) { //70831844f130498bb7ad798bdb54cf3a
								if(data.data.Code == 0) {
									if(data.data.Result.orderSeat) {
										that.orderSeat = data.data.Result.orderSeat;
										that.title = Number(that.todos.item.settlePriceForMerchant * data.data.Result.orderSeat.length).toFixed(2);
									}
									var _this = that;
									var lie, txt, txt1;
									if(_this.orderSeat.length >= 1) {
										for(var i = 0; i < _this.orderSeat.length; i++) {
											for(var j = 0; j < _this.seats.length; j++) {
												if(_this.orderSeat[i].rowId == _this.seats[j].rowList[0].rowId) {
													for(var x = 0; x < _this.seats[j].rowList.length; x++) {
														if(_this.orderSeat[i].columnId == _this.seats[j].rowList[x].columnId) {
															if(_this.seats[j].rowList[x].origStatus) {
																if(_this.seats[j].rowList[x].origStatus == "L") {
																	_this.seats[j].rowList[x].status = "LY";
																	Array.prototype.removeByValue = function(val) {
																		for(var i = 0; i < this.length; i++) {
																			if(this[i] == val) {
																				this.splice(i, 1);
																				break;
																			}
																		}
																	}
																	if(_this.about) {
																		lie = parseInt(_this.seats[j].rowList[x].columnId) + 1;
																	} else {
																		lie = parseInt(_this.seats[j].rowList[x].columnId) - 1;
																	}
																	lie = lie < 10 ? '0' + lie : lie;
																	txt = _this.seats[j].rowList[x].rowId + "排" + _this.seats[j].rowList[x].columnId + "座";
																	txtl = _this.seats[j].rowList[x].rowId + "排" + lie + "座";
																	_this.SelectQl.push(txt);
																	_this.SelectQl.push(txtl);
																} else if(_this.seats[j].rowList[x].origStatus == "R") {
																	_this.seats[j].rowList[x].status = "R"
																}
															} else {
																_this.seats[j].rowList[x].status = "Y";
																Array.prototype.removeByValue = function(val) {
																	for(var i = 0; i < this.length; i++) {
																		if(this[i] == val) {
																			this.splice(i, 1);
																			break;
																		}
																	}
																}
																txt = _this.seats[j].rowList[x].rowId + "排" + _this.seats[j].rowList[x].columnId + "座";
																_this.Select.push(txt);
															}
														}
													}
												}
											}

										}
									}
								}
							}, function(s) {

							});
						}
						that.$loading.hide();
					}

				}, function(s) {

					this.$loading.hide();
				});
			},
			warp: function(item) { //普通座位选中
				let that = this;
				this.ql = false;
				Array.prototype.removeByValue = function(val) {
					for(var i = 0; i < this.length; i++) {
						if(this[i] == val) {
							this.splice(i, 1);

							break;
						}
					}
				}
				var txt = item.rowId + "排" + item.columnId + "座";
				if(item.status != 'LK' || item.status != "E") {
					if(item.status == "N") {
						if(this.Select.length + this.SelectQl.length >= this.buyNumLimit) {
							that.$toast('每次最多可选' + this.buyNumLimit + '个座位');
							return false;
						} else {
							item.status = "Y";
							this.Select.push(txt);
							let length = this.Select.length + this.SelectQl.length;
							this.price = this.todos.item.settlePriceForMerchant * length;
							console.log(this.price);
							this.title = Number(this.price).toFixed(2);
							this.isp = true;
						}
					} else if(item.status == "Y") {
						item.status = "N";
						this.Select.removeByValue(txt);
						let length = this.Select.length + this.SelectQl.length;
						this.price = this.todos.item.settlePriceForMerchant * length;
						this.title = Number(this.price).toFixed(2);
						if(length < 1) {
							this.isp = false;
						}

					}
				}
				this.selects.push(item);
			},
			warps: function(item) { //情侣座位选中
				let that = this;
				this.ql = true;
				Array.prototype.removeByValue = function(val) {
					for(var i = 0; i < this.length; i++) {
						if(this[i] == val) {
							this.splice(i, 1);
							break;
						}
					}
				}
				var lie = "";
				lie = parseInt(item.columnId) + 1;
				lie = lie < 10 ? lie : lie;
				var txt = item.rowId + "排" + item.columnId + "座";
				var txtl = item.rowId + "排" + lie + "座";
				if(item.status == "L") {
					if(this.Select.length + this.SelectQl.length >= this.buyNumLimit) {
						that.$toast('每次最多可选' + this.buyNumLimit + '个座位');
						return false;
					} else if(this.buyNumLimit - this.Select.length - this.SelectQl.length < 2) {
						that.$toast('每次最多可选' + this.buyNumLimit + '个座位');
						return false;
					} else {
						item.status = "LY"
						this.SelectQl.push(txt);
						this.SelectQl.push(txtl);
						let length = this.Select.length + this.SelectQl.length;
						this.price = this.todos.item.settlePriceForMerchant * length;
						this.title = Number(this.price).toFixed(2);
						this.isp = true;
					}
				} else if(item.status == "LY") {
					item.status = "L"
					this.SelectQl.removeByValue(txt)
					this.SelectQl.removeByValue(txtl)
					let length = this.Select.length + this.SelectQl.length;
					this.price = this.todos.item.settlePriceForMerchant * length;
					this.title = Number(this.price).toFixed(2);
					if(length < 1) {
						this.isp = false;
					}
				}
			},
			cancel: function(item) { //普通座位删除
				this.Select.removeByValue(item);
				for(var i = 0; i < this.seats.length; i++) {
					for(var j = 0; j < this.seats[i].rowList.length; j++) {
						if(this.seats[i].rowList[j].rowId + "排" + this.seats[i].rowList[j].columnId + "座" == item) {
							this.seats[i].rowList[j].status = "N";
						}
					}
				}
			},
			cancels: function(item) { //情侣座位删除
				var lie, txt;
				for(var i = 0; i < this.seats.length; i++) {
					for(var j = 0; j < this.seats[i].rowList.length; j++) {
						if(this.seats[i].rowList[j].rowId + "排" + this.seats[i].rowList[j].columnId + "座" == item) {
							if(this.seats[i].rowList[j].status == "R") {
								this.SelectQl.removeByValue(item);
								if(this.about) {
									lie = parseInt(this.seats[i].rowList[j].columnId) - 1;
								} else {
									lie = parseInt(this.seats[i].rowList[j].columnId) + 1;
								}
								lie = lie < 10 ? '0' + lie : lie;
								txt = this.seats[i].rowList[j].rowId + "排" + lie + "座";
								this.SelectQl.removeByValue(txt);
								this.seats[i].rowList[j - 1].status = "L";
							} else if(this.seats[i].rowList[j].status == "LY") {
								this.SelectQl.removeByValue(item);
								if(this.about) {
									lie = parseInt(this.seats[i].rowList[j].columnId) + 1;
								} else {
									lie = parseInt(this.seats[i].rowList[j].columnId) - 1;
								}
								lie = lie < 10 ? '0' + lie : lie;
								txt = this.seats[i].rowList[j].rowId + "排" + lie + "座";
								this.SelectQl.removeByValue(txt);
								this.seats[i].rowList[j].status = "L";
							}
						}
					}
				}
			},
			placeOrder: function() { //购票

				let that = this;
				this.Ticket = true;
				this.Tickets = true;
				var arr = [];
				var side = "";
				var index = null;
				this.seatsJSON.count = "";
				this.seatsJSON.list = [];
				var l1, l2, r1, r2;
				for(var i = 0; i < that.$refs.div.length; i++) { //中间
					if(that.$refs.div[i].attributes["type"].value == "Y") {
						var jsonval = that.$refs.div[i].attributes["data-info"].value;
						var json = eval('(' + jsonval + ')');
						var s = json.sectionsID;
						//						console.log(s);
						delete json.sectionsID;
						json.sectionId = s;
						delete json.status;
						this.seatsJSON.list.push(json);
						l1 = that.$refs.div[i].parentNode.previousSibling == null ? 'Y' : that.$refs.div[i].parentNode.previousSibling.children["0"].attributes.type.value;
						r1 = that.$refs.div[i].parentNode.nextSibling == null ? 'Y' : that.$refs.div[i].parentNode.nextSibling.children["0"].attributes.type.value;
						if(that.$refs.div[i].parentNode.previousSibling != null) {
							l2 = that.$refs.div[i].parentNode.previousSibling.previousSibling == null ? 'Y' : that.$refs.div[i].parentNode.previousSibling.previousSibling.children["0"].attributes.type.value;
						}
						if(that.$refs.div[i].parentNode.nextSibling != null) {
							if(that.$refs.div[i].parentNode.nextSibling.children["0"].attributes.type.value == 'L' || that.$refs.div[i].parentNode.nextSibling.children["0"].attributes.type.value == 'LY') {
								r2 = 'Y'
							} else {
								r2 = that.$refs.div[i].parentNode.nextSibling.nextSibling == null ? 'Y' : that.$refs.div[i].parentNode.nextSibling.nextSibling.children["0"].attributes.type.value;
							}

						}
						arr.push({
							l1: l1,
							l2: l2,
							r1: r1,
							r2: r2
						});
						if((l1 == "N" && l2 == "Y") || (r1 == "N" && r2 == "Y")) {
							this.Ticket = false;
							break;
						} else {
							this.Ticket = true;
						}
					}
					if(that.$refs.div[i].attributes["type"].value == "LY") {
						var jsonval = that.$refs.div[i].attributes["data-info"].value;
						//						var json = JSON.parse(jsonval);
						var json = eval('(' + jsonval + ')');
						var s = json.sectionsID;
						delete json.sectionsID;
						json.sectionId = s;
						delete json.status;
						this.seatsJSON.list.push(eval('(' + jsonval + ')'));
						var jsonqlval = that.$refs.div[i].parentNode.nextSibling.children["0"].attributes["data-info"].value;
						var jsonql = eval('(' + jsonqlval + ')');
						var sql = jsonql.sectionsID;
						delete jsonql.sectionsID;
						jsonql.sectionId = sql;
						delete jsonql.status;
						this.seatsJSON.list.push(eval('(' + jsonqlval + ')'));
					}
				}
				this.seatsJSON.count = "" + this.seatsJSON.list.length + "";
				sessionStorage.setItem("seatsJSON", JSON.stringify(this.seatsJSON)); //存储座位数据
				if(this.Ticket) { //旁边
					for(var i = 0; i < arr.length; i++) {
						if((arr[i].l1 && arr[i].l1 != "E" && arr[i].l1 != "LK") && (arr[i].r1 && arr[i].r1 != "E" && arr[i].r1 != "LK")) {
							if(arr[i].l1 == "N" && arr[i].l2 != "N") {
								index = i;
								this.Tickets = false;
							} else if(arr[i].r1 == "N" && arr[i].r2 != "N") {
								index = i;
								this.Tickets = false;
							}
						} else {
							side = true;
						}

					}
					if(index !== null) {
						if(side && arr[index].l2 != "N" && arr[index].r2 != "N") {
							this.Tickets = true;
						}
					}
				}
				if(!this.Ticket) {
					that.$toast('座位中间不要留空');
				} else {
					if(!this.Tickets) {
						that.$toast('座位旁边不要留空');
					} else {
						if(this.userInfo.userID) { //已登录
							if(this.userInfo.IDNo) { //如果实名认证了
								this.$loading.show();
								//								that.$toast('订单创建中');
								//获取机型
								//								var ipaddres = returnCitySN["cip"]; //获取ip地址
								//								var deviceID = " "; //机型
								//								if(mui.os.iphone) {
								//									deviceID = "iPhone";
								//								} else if(mui.os.android) {
								//									deviceID = "android";
								//								} else if(mui.os.ipad) {
								//									deviceID = "ipad";
								//								}
								//								var os = " "; // 版本
								//								if(mui.os.version) {
								//									os = mui.os.version;
								//								}

								let totalPrice = Math.round(this.price);
								console.log(totalPrice)
								let seatsJSON = JSON.stringify(this.seatsJSON);

								let param = {
									'userID': this.userInfo.userID,
									'payMoney': Number(totalPrice), //实际支付金额
									'totalPrice': totalPrice, //订单总金额
									'activityID': "-1", //活动id
									'cinemaId': Number(this.todos.cinemaid), //影院id
									'cinemaName': this.todos.cinemaName, //影院名称
									'hallCode': this.todos.item.hallCode, //影厅编码
									'hallName': this.todos.item.hallName, //影厅名字
									'filmId': this.todos.item.filmId, //影片id
									'filmName': this.todos.item.filmName, //影片名称
									'showId': this.todos.item.showId, //影讯id
									'showStartTime': this.todos.item.showTime, //放映开始时间
									'settlePriceForMerchant': Number(this.todos.item.settlePrice), //渠道结算价
									'settlePriceForCinema': this.todos.item.settlePriceForCinema, //影院结算价
									'fee': Number(this.todos.item.fee), //猫眼服务费
									'price': this.todos.item.price, //原价
									'minPrice': this.todos.item.fee, //最低价
									'contactName': this.userInfo.userName, //联系人姓名
									'contactMobile': this.userInfo.phone, //联系人电话
									'language': this.todos.item.language, //放映语言
									'showVersionType': this.todos.item.showVersionType, //影讯版本
									'channels': 3,
									'seatsJSON': seatsJSON, //选中座位信息
									//									'seatsJSON': "{\"count\":1,\"list\":[{\"sectionId\":\"0000000000000001\",\"seatNo\":\"0000000000000001-6-08\",\"columnId\":\"08\",\"rowId\":\"6\"}]}", //选中座位信息
									'deviceID': '', //机型
									'model': "",
									'os': '', //手机版本
									'ip': '', //ip
									'avatar': this.todos.item.avatar,
									'movieDur': this.todos.item.duration,
									'wxApplet': 'wxApplet'

								};
								//								var header = {"token":this.userInfo.token};
								this.$http.get(this.$baseUrl.baseurl + 'mymovie/movie/appSaveOrder', param).then((res) => {
									if(res.data.Code == 0) {
										that.$router.push({
											path: '/index/film/pay',
											query: {
												//												"result":JSON.stringify(res.data.Result)
												"lockSurTime": res.data.Result.lockSurTime,
												"orderNum": res.data.Result.order_num,
											}
										})
										this.$loading.hide();
										//										sessionStorage.setItem("order_num", data.data.Result.order_num)
										//										localStorage.setItem("paySeat", JSON.stringify(data.data.Result));
										//										if(typeof WeixinJSBridge == "undefined") {
										//											window.location.replace('pay.html');
										//										} else {
										//											window.location.replace('https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx348ec18fec6bf757&redirect_uri=http%3a%2f%2fh5.kpchuxing.com%2ffilm%2fpay.html&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect');
										//										}
										//	
									} else if(res.data.Code == 3) {
										this.$loading.hide();
										that.$toast('请登录');
										that.$router.push({
											path: '/login',
										})
									} else {
										this.$loading.hide();
										//"102 上映开始X分钟前禁止售卖
										that.$toast(res.data.msg);
									}
								}).catch((err) => {
									this.$loading.hide();
									console.log(err);
								})
							} else {
								this.$router.push({
									path: '/realName',
								})

							}
						} else { //未登录
							this.$router.push({
								path: '/login',
							})
						}
					}
				}

			},

			back: function() { //用户已选座位信息
				var _this = this;
				if(this.SelectQl.length + this.Select.length >= 1) {
					var btnArray = ['继续选座', '返回'];
					mui.confirm('返回后您当前选中的座位将不再保留', '提示', btnArray, function(e) {
						if(e.index == 1) {
							var timestamp = new Date().format('yyyy-MM-dd hh');
							var paramObj = {
								orderNum: sessionStorage.getItem("order_num"),
								orderType: '6'
							};
							_this.$http.post(this.$baseUrl.baseurl + 'KPCX/appPersonalCenter/cancelMyOrder', paramObj, {
								emulateJSON: true
							}).then(function(data) {
								//								console.log(data);
								if(data.data.Code == 0) {
									window.history.go(-1);
								}
							}, function(s) {
								console.log(s)
							});
						} else {
							return;
						}
					})
				} else {
					window.history.go(-1);
				}
			},
			pics: function() { //触摸
				var _this = this;
				//				document.getElementById('middle').getBoundingClientRect().left
				(function() {
					var Pic = function(id) {
						this._config = {},
							this._id = document.querySelector(id);
						this._seatsBlock = document.querySelector('.seats-block');
						this._leftList = document.querySelector('.left-list');
						this.middle = document.getElementById('middle');
						this.mc = new Hammer.Manager(this._id);
						this.timer = false;
						this.translateX = 0;
						this.translateY = 0;
						this.scale = _this.scale;
						this.firstTouch = true; //用户第一次触摸
						this._relateX = 0;
						this._relateY = 0;
						this._oldX = 0;
						this._oldY = 0;
						this._oldScale = _this.scale;
						this.middleLeft = 0;
					}
					Pic.prototype = {
						constructor: Pic,
						picAnimate: function() {
							return window[Hammer.prefixed(window, 'requestAnimationFrame')] || function(callback) {
								setTimeout(callback, 1000 / 60);
							};
						},
						_setPosition: function() {
							var that = this;
							var _relateX = 0;
							var _relateY = 0;
							var _relateTop = 0;
							var _relateLeft = 0;
							_relateTop = this._id.offsetTop;
							_relateLeft = this._id.offsetLeft;

							_relateX = ((document.body.clientWidth || document.documentElement.clientWidth) - _relateTop) / 2;
							_relateY = ((document.body.clientHeight || document.documentElement.clientHeight) - _relateLeft) / 2;
							that._selfPosition({
								translateX: that._relateX,
								translateY: that._relateY,
								scale: that.scale
							})

						},
						_selfPosition: function(pos) {

							var that = this;
							var _pos = function() {
								var _style = [
									'translate3d(' + pos.translateX + 'px,' + pos.translateY + 'px,0)',
									'scale(' + pos.scale + ',' + pos.scale + ')'
								];
								var _style2 = [
									'translate3d(' + pos.translateX + 'px,0px,0)',
									'scale(' + pos.scale + ',' + pos.scale + ')'
								];
								_style = _style.join(' ');
								_style2 = _style2.join(' ');
								that._id.style.transform = _style;
								document.querySelector('#yinmu').style.transform = _style2;
								document.querySelector('#center_movie').style.transform = _style2;
							};
							that._picAnimate(_pos);

						},
						_picAnimate: function(fn) {
							return this.picAnimate()(fn);
						},
						onPan: function(ev) {
							var that = this;

							that.translateX = ev.deltaX;
							that.translateY = ev.deltaY;

							that._position = {
								translateX: ev.deltaX,
								translateY: ev.deltaY,
								scale: that.scale
							};
						},
						onPinch: function() {
							var that = this;

							that.scale *= ev.scale;

							that._selfPosition({
								translateX: that.translateX,
								translateY: that.translateY,
								scale: that.scale
							})

						},
						picInit: function() {
							var that = this;
							var _that = this;
							that.mc.on("hammer.input", function(ev) {
								if(ev.isFinal) {
									//that._setPosition();
									that._oldX = that.translateX;
									that._oldY = that.translateY;
									that._oldScale = that.scale;
								}
							})
							that.mc.add(new Hammer.Pan({
								direction: Hammer.DIRECTION_ALL,
								threshold: 0,
								pointers: 0
							}));
							that.mc.add(new Hammer.Pinch({
								threshold: 0
							})).recognizeWith(that.mc.get('pan'));

							that.mc.on('panstart panmove', _onPan);
							that.mc.on('pinchstart pinchmove', _onPinch);

							that._setPosition();

							function _onPan(ev) { //平移v)
								if(that.firstTouch) {
									that._oldX = that._relateX;
									that._oldY = that._relateY;
								};
								that.translateX = that._oldX + ev.deltaX;
								that.translateY = that._oldY + ev.deltaY;
								var _position = {
									translateX: that.translateX,
									translateY: that.translateY,
									scale: that.scale
								};

								if(screen.width > that._id.clientWidth) {
									that.translateX = _position.translateX = 0;
								} else {
									if(that.translateX > (that._id.clientWidth - screen.width) / 2 + 30) {
										that.translateX = _position.translateX = (that._id.clientWidth - screen.width) / 2 + 30;
									}
									if(that.translateX < (screen.width - that._id.clientWidth) / 2 - 30) {
										that.translateX = _position.translateX = (screen.width - that._id.clientWidth) / 2 - 30;

									}
								}
								if(that._seatsBlock.clientHeight > that._id.clientHeight) {
									that.translateY = _position.translateY = 20;
								} else {
									if(that.translateY > (that._id.clientHeight - that._seatsBlock.clientHeight) / 2 + 500) {
										that.translateY = _position.translateY = (that._id.clientHeight - that._seatsBlock.clientHeight) / 2 + 500;
									}
									if(that.translateY < (that._seatsBlock.clientHeight - that._id.clientHeight) / 2 - 500) {
										that.translateY = _position.translateY = (that._seatsBlock.clientHeight - that._id.clientHeight) / 2 - 500;
									}
								}

								that._selfPosition(_position);
								var screenWidth = document.body.clientWidth;
								var screenWidthRatio = screenWidth / 750;
								//								console.log(screenWidth, screenWidthRatio)
								that.middleLeft = document.getElementById('middle').getBoundingClientRect().left;
								var numLeft = -350 - ((document.getElementById('middle').getBoundingClientRect().left + 1) - screenWidth / 2) / screenWidthRatio;
								that._leftList.style.transform = "translate3d(" + numLeft / 75 + "rem, 0px, 0px) scale(" + that.scale + ")";

								that.firstTouch = false;

							};

							function _onPinch(ev) { //缩放
								that.scale = that._oldScale * ev.scale;

								if(that.scale >= 2) {
									that.scale = 2;

								}
								if(that.scale <= 0.5) {
									that.scale = 0.5;

								}
								that._selfPosition({
									translateX: that.translateX,
									translateY: that.translateY,
									scale: that.scale
								})
								that._selfPosition(that._position);
								var screenWidth = document.body.clientWidth;
								var screenWidthRatio = screenWidth / 750;
								if(that.middleLeft) {
									var numLeft = -350 - ((that.middleLeft + 2) - screenWidth / 2) / screenWidthRatio;
									numLeft = numLeft / that.scale;
									that._leftList.style.transform = "translate3d(" + numLeft / 75 + "rem, 0px, 0px) scale(" + that.scale + ")";
								} else {
									var numLeft = -350 - ((document.getElementById('middle').getBoundingClientRect().left + 2) - screenWidth / 2) / screenWidthRatio;
									numLeft = numLeft / that.scale;
									that._leftList.style.transform = "translate3d(" + numLeft / 75 + "rem, 0px, 0px) scale(" + that.scale + ")";
								}

							};

						}
					}
					window.Pic = Pic;
				})()
				var pic = new Pic('#touchs');
				pic.picInit();

			},
			pict() { //触摸
				var _this = this;

			},
			getdata() {
				this.cinemaId = this.$route.query.cinemaid
			}

		},
		created() {
			this.getdata();
		},
		watch: { //监听放置
			"$route": 'getdata'
		},
		components: {
			Realname
		},
		computed: {
			...mapState({
				userInfo: state => state.common.userinfo,
			})
		}
	}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
	body,
	html {
		width: 100%;
		height: 100%;
	}
	
	.seat-top {
		padding: 0 30px;
		border-bottom: 1px solid #e5e5e5;
		padding-top: 86px;
		background: #fff;
	}
	
	.seat-top p:first-child {
		color: rgb(51, 51, 51);
		font-size: 16px;
		padding-top: 27px;
		font-family: PingFang-SC-Medium;
		font-size: 32px;
		font-weight: normal;
		font-stretch: normal;
		letter-spacing: 1px;
		color: #333333;
		margin-bottom: 19px;
	}
	
	.seat-top p:last-child {
		color: rgb(102, 102, 102);
		font-family: PingFang-SC-Medium;
		font-size: 26px;
		font-weight: normal;
		font-stretch: normal;
		letter-spacing: 1px;
		padding-bottom: 30px;
		color: #666666;
	}
	
	.seat-top p:last-child span {
		margin-left: 0.266666rem;
	}
	
	.select-block {
		/*width: 100%;*/
		background: #f0f0f0;
		/*overflow: hidden;*/
		display: flex;
		justify-content: center;
		align-items: center;
		position: relative;
		overflow: hidden;
		height: 1000px;
	}
	
	.hall-name-wrapper {
		width: 380px;
		height: 35px;
		background: #dcdcdc;
		position: absolute;
		left: 50%;
		margin-left: -190px;
		top: 0;
		border-radius: 0 0 12px 12px;
		text-align: center;
		line-height: 35px;
		color: #888;
		z-index: 50;
	}
	
	.hall-name-wrapper span {
		font-family: PingFang-SC-Medium;
		font-size: 20px;
		font-weight: normal;
		font-stretch: normal;
		letter-spacing: 0px;
		color: #666666;
	}
	
	.warp-center {
		width: 100%;
		color: #9c9c9c;
		font-size: 20px;
		text-align: center;
		margin-top: 30px;
		margin-bottom: 30px;
		position: absolute;
		top: 40px;
		left: 0;
		z-index: 50;
		text-align: center;
		display: flex;
		justify-content: center;
	}
	
	.warp-center span {
		border: 1px solid #d2d2d2;
		border-radius: 4px;
		padding: 0.066666rem 0.12rem;
	}
	
	.seats-block {
		display: flex;
		justify-content: center;
		align-items: center;
		flex-direction: column;
		min-width: 250%;
		position: absolute;
		left: -75%;
		top: 0;
	}
	
	.setcon {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		position: relative;
		z-index: 5;
	}
	
	.seats-wrap {
		position: relative;
		text-align: center;
		white-space: nowrap;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		min-width: 250%;
		/*background: #f0f0f0;*/
	}
	
	.seats {
		width: 100%;
		height: 48px;
	}
	
	.wrap {
		display: inline-block;
		padding: 0 6px;
		width: 40px;
		height: 34px;
	}
	
	.wrapL {
		display: inline-block;
		padding: 0 6px;
		width: 92px;
		height: 34px;
	}
	
	.wrapR {
		display: inline-block;
		width: 0;
		padding: 0;
		height: 34px;
	}
	
	.seat {
		width: 40px;
		height: 34px;
		/*background-size: 100% 100%;*/
	}
	
	.seat-L {
		width: 0.8rem;
		height: 0.36rem;
		/*background-size: 100% 100%;*/
	}
	
	.seat img,
	.seat-L img {
		width: 100%;
		height: 100%;
	}
	
	.cinema-info {
		width: 100%;
		position: absolute;
		left: 0;
		bottom: 20px;
	}
	
	.cinema-info .seat-type-info {
		width: 100%;
		overflow: hidden;
		text-align: center;
		display: flex;
		flex-direction: row;
		justify-content: space-around;
		align-items: center;
	}
	
	.cinema-info .seat-type-info p {
		float: left;
		/*margin-right: 0.626666rem;*/
		font-size: 12px;
		color: #666;
	}
	
	.cinema-info .seat-type-info p:first-child {
		/*margin-left: 0.773333rem;*/
	}
	
	.cinema-info .seat-type-info p:last-child {
		margin-right: 0;
	}
	
	.cinema-info .seat-type-info p span:first-child {
		float: left;
		width: 40px;
		height: 38px;
		margin-right: 17px;
	}
	
	.cinema-info .seat-type-info p span:last-child {
		float: left;
		font-family: PingFang-SC-Medium;
		font-size: 24px;
		font-weight: normal;
		font-stretch: normal;
		line-height: 38px;
		letter-spacing: 1px;
		color: #666666;
	}
	
	.cinema-info .seat-type-info p:nth-child(1) span:first-child {
		background: url("../assets/zuowei-kexuan@2x.png");
		background-size: 100% 100%;
	}
	
	.cinema-info .seat-type-info p:nth-child(2) span:first-child {
		background: url("../assets/zuowei-bukexuan@2x.png");
		background-size: 100% 100%;
	}
	
	.cinema-info .seat-type-info p:nth-child(3) span:first-child {
		background: url("../assets/zuowei-yixuan@2x.png");
		background-size: 100% 100%;
	}
	
	.cinema-info .seat-type-info p:nth-child(4) span:first-child {
		background: url("../assets/zuowei-qinglvzuo@2x.png");
		background-size: 100% 100%;
		width: 1.053333rem;
	}
	
	.submit-block {
		width: 690px;
		height: 90px;
		background: #90e1e2;
		margin: 20px 30px;
	}
	
	.co_cine {
		height: 130px;
		display: block;
	}
	
	.submit-block p {
		width: 100%;
		height: 100%;
		text-align: center;
		line-height: 1.2rem;
		color: #fff;
		font-size: 18px;
	}
	
	.seat-selection {
		padding: 30px;
	}
	
	.seat-selection p {
		color: #333;
		font-size: 30px;
		margin: 26px 30px;
	}
	
	.seat-selection .seat-selection-list {
		width: 100%;
		height: auto;
		display: flex;
		flex-wrap: wrap;
		justify-content: flex-start;
	}
	
	.seat-selection .seat-selection-list .list {
		width: 160px;
		height: 0.973333rem;
		background: url("../assets/piao@2x.png");
		background-size: 100% 100%;
		display: flex;
		display: -webkit-flex;
		align-items: center;
		flex-direction: column;
		position: relative;
		margin-right: 0.133333rem;
		margin-bottom: 0.133333rem;
	}
	
	.seat-selection .seat-selection-list .list span:nth-child(1) {
		color: #333;
		font-size: 20px;
		margin-top: 10px;
	}
	
	.seat-selection .seat-selection-list .list span:nth-child(2) {
		color: #e13d1a;
		font-size: 20px;
		margin-top: 10px;
	}
	
	.seat-selection .seat-selection-list .list span:nth-child(3) {
		width: 0.213333rem;
		height: 0.2rem;
		position: absolute;
		right: 0.12rem;
		top: 50%;
		margin-top: -0.2rem;
	}
	
	.seat-selection .seat-selection-list .list span:nth-child(3) img {
		width: 100%;
		height: 100%;
	}
	
	.mui-popup-button {
		color: #3cc4c0 !important;
	}
	
	.mui-popup-title+.mui-popup-text {
		color: #333 !important;
	}
	
	.submit-block {
		width: 690px;
		height: 90px;
		background-color: #8fe2e1;
		border-radius: 8px;
	}
	
	.submit-block.active {
		background-color: #61cdc5;
	}
	
	.submit-block p {
		width: 100%;
		height: 100%;
		text-align: center;
		line-height: 90px;
		font-family: PingFang-SC-Medium;
		font-size: 36px;
		font-weight: normal;
		font-stretch: normal;
		letter-spacing: 1px;
		color: #ffffff;
	}
	
	.seat_divbox {
		position: fixed;
		left: 0;
		bottom: 0;
		background: #fff;
		z-index: 5;
	}
	
	.cinema-info {
		position: fixed;
		bottom: 140px;
		width: 100%;
	}
	/*中线  */
	
	.middle {
		width: 0;
		height: 100%;
		border-left: 3px dashed #ccc;
		position: absolute;
		top: 0%;
		left: 50%;
		z-index: 1;
		display: inline-block;
	}
	/*辅助行列*/
	
	.left-list {
		position: absolute;
		top: 0%;
		left: 50%;
		z-index: 30;
		background-color: rgba(0, 0, 0, 0.6);
		border-radius: 20px;
		font-size: 30px;
		padding: 5px;
		text-align: center;
		/* transform: translateX(-350px); */
		transition: all 0.2s;
	}
	
	.left-list .list {
		/* line-height: 52px; */
		height: 45px;
		font-size: 30px;
		display: flex;
		align-items: center;
		justify-content: center;
		color: #fff;
		width: 30px;
	}
	
	img.set {
		width: 40px;
		height: 34px;
		/*margin: 5px 2px;*/
	}
	
	img.setL {
		width: 92px;
		height: 34px;
		/*margin: 5px 2px;*/
	}
	
	img.setR {
		width: 0px;
		height: 34px;
		/* margin: 5px 2px; */
	}
</style>